﻿#region Using Directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;

using EcomProduct.Entities;
using EcomProduct.Data;
using EcomProduct.Data.Bases;
#endregion

namespace EcomProduct.Web.Data
{
	/// <summary>
	/// Represents the DataRepository.ArticleProvider object that provides
	/// data to data-bound controls in multi-tier Web application architectures.
	/// </summary>
	[Designer(typeof(ArticleDataSourceDesigner))]
	public class ArticleDataSource : ProviderDataSource<Article, ArticleKey>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ArticleDataSource class.
		/// </summary>
		public ArticleDataSource() : base(DataRepository.ArticleProvider)
		{
		}

		#endregion Constructors
		
		#region Properties
		
		/// <summary>
		/// Gets a reference to the ArticleDataSourceView used by the ArticleDataSource.
		/// </summary>
		protected ArticleDataSourceView ArticleView
		{
			get { return ( View as ArticleDataSourceView ); }
		}
		
		/// <summary>
		/// Gets or sets the name of the method or function that
		/// the ArticleDataSource control invokes to retrieve data.
		/// </summary>
		public ArticleSelectMethod SelectMethod
		{
			get
			{
				ArticleSelectMethod selectMethod = ArticleSelectMethod.GetAll;
				Object method = ViewState["SelectMethod"];
				if ( method != null )
				{
					selectMethod = (ArticleSelectMethod) method;
				}
				return selectMethod;
			}
			set { ViewState["SelectMethod"] = value; }
		}

		#endregion Properties
		
		#region Methods

		/// <summary>
		/// Creates a new instance of the ArticleDataSourceView class that is to be
		/// used by the ArticleDataSource.
		/// </summary>
		/// <returns>An instance of the ArticleDataSourceView class.</returns>
		protected override BaseDataSourceView<Article, ArticleKey> GetNewDataSourceView()
		{
			return new ArticleDataSourceView(this, DefaultViewName);
		}
		
		/// <summary>
        /// Creates a cache hashing key based on the startIndex, pageSize and the SelectMethod being used.
        /// </summary>
        /// <param name="startIndex">The current start row index.</param>
        /// <param name="pageSize">The current page size.</param>
        /// <returns>A string that can be used as a key for caching purposes.</returns>
		protected override string CacheHashKey(int startIndex, int pageSize)
        {
			return String.Format("{0}:{1}:{2}", SelectMethod, startIndex, pageSize);
        }
		
		#endregion Methods
	}
	
	/// <summary>
	/// Supports the ArticleDataSource control and provides an interface for
	/// data-bound controls to perform data operations with business and data objects.
	/// </summary>
	public class ArticleDataSourceView : ProviderDataSourceView<Article, ArticleKey>
	{
		#region Declarations

		#endregion Declarations
		
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ArticleDataSourceView class.
		/// </summary>
		/// <param name="owner">A reference to the ArticleDataSource which created this instance.</param>
		/// <param name="viewName">The name of the view.</param>
		public ArticleDataSourceView(ArticleDataSource owner, String viewName)
			: base(owner, viewName)
		{
		}
		
		#endregion Constructors
		
		#region Properties

		/// <summary>
		/// Gets a strongly-typed reference to the Owner property.
		/// </summary>
		internal ArticleDataSource ArticleOwner
		{
			get { return Owner as ArticleDataSource; }
		}

		/// <summary>
		/// Gets or sets the name of the method or function that
		/// the DataSource control invokes to retrieve data.
		/// </summary>
		internal ArticleSelectMethod SelectMethod
		{
			get { return ArticleOwner.SelectMethod; }
			set { ArticleOwner.SelectMethod = value; }
		}

		/// <summary>
		/// Gets a strongly typed reference to the Provider property.
		/// </summary>
		internal ArticleProviderBase ArticleProvider
		{
			get { return Provider as ArticleProviderBase; }
		}

		#endregion Properties
		
		#region Methods
		
		/// <summary>
		/// Gets a collection of Entity objects based on the value of the SelectMethod property.
		/// </summary>
		/// <param name="count">The total number of rows in the DataSource.</param>
		/// <returns>A collection of Entity objects.</returns>
		protected override IList<Article> GetSelectData(out int count)
		{
			Hashtable values = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
			Hashtable customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
			IList<Article> results = null;
			Article item;
			count = 0;
			
			System.String _alias_nullable;
			System.Boolean _isDisabled;
			System.Boolean _isRemoved;
			System.Int64 _id;
			System.String _language;
			System.Int64 _originalId;

			switch ( SelectMethod )
			{
				case ArticleSelectMethod.Get:
					ArticleKey entityKey  = new ArticleKey();
					entityKey.Load(values);
					item = ArticleProvider.Get(GetTransactionManager(), entityKey);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetAll:
                    results = ArticleProvider.GetAll(GetTransactionManager(), StartIndex, PageSize, out count);
                    break;
				case ArticleSelectMethod.GetPaged:
					results = ArticleProvider.GetPaged(GetTransactionManager(), WhereClause, OrderBy, PageIndex, PageSize, out count);
					break;
				case ArticleSelectMethod.Find:
					if ( FilterParameters != null )
						results = ArticleProvider.Find(GetTransactionManager(), FilterParameters, OrderBy, StartIndex, PageSize, out count);
					else
						results = ArticleProvider.Find(GetTransactionManager(), WhereClause, StartIndex, PageSize, out count);
                    break;
				// PK
				case ArticleSelectMethod.GetById:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					item = ArticleProvider.GetById(GetTransactionManager(), _id);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				// IX
				case ArticleSelectMethod.GetByAlias:
					_alias_nullable = (System.String) EntityUtil.ChangeType(values["Alias"], typeof(System.String));
					item = ArticleProvider.GetByAlias(GetTransactionManager(), _alias_nullable);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByAliasIsDisabled:
					_alias_nullable = (System.String) EntityUtil.ChangeType(values["Alias"], typeof(System.String));
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByAliasIsDisabled(GetTransactionManager(), _alias_nullable, _isDisabled);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByAliasIsDisabledIsRemoved:
					_alias_nullable = (System.String) EntityUtil.ChangeType(values["Alias"], typeof(System.String));
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByAliasIsDisabledIsRemoved(GetTransactionManager(), _alias_nullable, _isDisabled, _isRemoved);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByAliasIsRemoved:
					_alias_nullable = (System.String) EntityUtil.ChangeType(values["Alias"], typeof(System.String));
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByAliasIsRemoved(GetTransactionManager(), _alias_nullable, _isRemoved);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdIsDisabled:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdIsDisabled(GetTransactionManager(), _id, _isDisabled);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdIsDisabledIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdIsDisabledIsRemoved(GetTransactionManager(), _id, _isDisabled, _isRemoved);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdIsRemoved(GetTransactionManager(), _id, _isRemoved);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdLanguage:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					item = ArticleProvider.GetByIdLanguage(GetTransactionManager(), _id, _language);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdLanguageIsDisabled:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdLanguageIsDisabled(GetTransactionManager(), _id, _language, _isDisabled);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdLanguageIsDisabledIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdLanguageIsDisabledIsRemoved(GetTransactionManager(), _id, _language, _isDisabled, _isRemoved);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdLanguageIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdLanguageIsRemoved(GetTransactionManager(), _id, _language, _isRemoved);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdOriginalId:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					item = ArticleProvider.GetByIdOriginalId(GetTransactionManager(), _id, _originalId);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdOriginalIdIsDisabled:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdOriginalIdIsDisabled(GetTransactionManager(), _id, _originalId, _isDisabled);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdOriginalIdIsDisabledIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdOriginalIdIsDisabledIsRemoved(GetTransactionManager(), _id, _originalId, _isDisabled, _isRemoved);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIdOriginalIdIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ArticleProvider.GetByIdOriginalIdIsRemoved(GetTransactionManager(), _id, _originalId, _isRemoved);
					results = new TList<Article>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ArticleSelectMethod.GetByIsDisabled:
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByIsDisabled(GetTransactionManager(), _isDisabled, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByIsDisabledIsRemoved:
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByIsDisabledIsRemoved(GetTransactionManager(), _isDisabled, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByIsRemoved:
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByIsRemoved(GetTransactionManager(), _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByLanguage:
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					results = ArticleProvider.GetByLanguage(GetTransactionManager(), _language, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByLanguageIsDisabled:
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByLanguageIsDisabled(GetTransactionManager(), _language, _isDisabled, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByLanguageIsDisabledIsRemoved:
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByLanguageIsDisabledIsRemoved(GetTransactionManager(), _language, _isDisabled, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByLanguageIsRemoved:
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByLanguageIsRemoved(GetTransactionManager(), _language, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByOriginalId:
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					results = ArticleProvider.GetByOriginalId(GetTransactionManager(), _originalId, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByOriginalIdIsDisabled:
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByOriginalIdIsDisabled(GetTransactionManager(), _originalId, _isDisabled, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByOriginalIdIsDisabledIsRemoved:
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByOriginalIdIsDisabledIsRemoved(GetTransactionManager(), _originalId, _isDisabled, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByOriginalIdIsRemoved:
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByOriginalIdIsRemoved(GetTransactionManager(), _originalId, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByOriginalIdLanguage:
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					results = ArticleProvider.GetByOriginalIdLanguage(GetTransactionManager(), _originalId, _language, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByOriginalIdLanguageIsDisabled:
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByOriginalIdLanguageIsDisabled(GetTransactionManager(), _originalId, _language, _isDisabled, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByOriginalIdLanguageIsDisabledIsRemoved:
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByOriginalIdLanguageIsDisabledIsRemoved(GetTransactionManager(), _originalId, _language, _isDisabled, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ArticleSelectMethod.GetByOriginalIdLanguageIsRemoved:
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ArticleProvider.GetByOriginalIdLanguageIsRemoved(GetTransactionManager(), _originalId, _language, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				// FK
				// M:M
				// Custom
				default:
					break;
			}

			if ( results != null && count < 1 )
			{
				count = results.Count;

				if ( !String.IsNullOrEmpty(CustomMethodRecordCountParamName) )
				{
					object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));
					
					if ( objCustomCount != null )
					{
						count = (int) objCustomCount;
					}
				}
			}
			
			return results;
		}
		
		/// <summary>
		/// Gets the values of any supplied parameters for internal caching.
		/// </summary>
		/// <param name="values">An IDictionary object of name/value pairs.</param>
		protected override void GetSelectParameters(IDictionary values)
		{
			if ( SelectMethod == ArticleSelectMethod.Get || SelectMethod == ArticleSelectMethod.GetById )
			{
				EntityId = GetEntityKey(values);
			}
		}

		/// <summary>
		/// Performs a DeepLoad operation for the current entity if it has
		/// not already been performed.
		/// </summary>
		internal override void DeepLoad()
		{
			if ( !IsDeepLoaded )
			{
				Article entity = GetCurrentEntity();
				
				if ( entity != null )
				{
					// execute deep load method
					ArticleProvider.DeepLoad(GetTransactionManager(), GetCurrentEntity(), EnableRecursiveDeepLoad);
					// set loaded flag
					IsDeepLoaded = true;
				}
			}
		}

		/// <summary>
		/// Performs a DeepLoad operation on the specified entity collection.
		/// </summary>
		/// <param name="entityList"></param>
		/// <param name="properties"></param>
		internal override void DeepLoad(TList<Article> entityList, ProviderDataSourceDeepLoadList properties)
		{
			// execute deep load method
			ArticleProvider.DeepLoad(GetTransactionManager(), entityList, properties.Recursive, properties.Method, properties.GetTypes());
		}

		#endregion Select Methods
	}
	
	#region ArticleDataSourceDesigner

	/// <summary>
	/// Provides design-time support in a design host for the ArticleDataSource class.
	/// </summary>
	public class ArticleDataSourceDesigner : ProviderDataSourceDesigner<Article, ArticleKey>
	{
		/// <summary>
		/// Initializes a new instance of the ArticleDataSourceDesigner class.
		/// </summary>
		public ArticleDataSourceDesigner()
		{
		}

		/// <summary>
		/// Gets or sets the SelectMethod property.
		/// </summary>
		public ArticleSelectMethod SelectMethod
		{
			get { return ((ArticleDataSource) DataSource).SelectMethod; }
			set { SetPropertyValue("SelectMethod", value); }
		}

		/// <summary>Gets the designer action list collection for this designer.</summary>
		/// <returns>The <see cref="T:System.ComponentModel.Design.DesignerActionListCollection"/>
		/// associated with this designer.</returns>
		public override DesignerActionListCollection ActionLists
		{
			get
			{
				DesignerActionListCollection actions = new DesignerActionListCollection();
				actions.Add(new ArticleDataSourceActionList(this));
				actions.AddRange(base.ActionLists);
				return actions;
			}
		}
	}

	#region ArticleDataSourceActionList

	/// <summary>
	/// Supports the ArticleDataSourceDesigner class.
	/// </summary>
	internal class ArticleDataSourceActionList : DesignerActionList
	{
		private ArticleDataSourceDesigner _designer;

		/// <summary>
		/// Initializes a new instance of the ArticleDataSourceActionList class.
		/// </summary>
		/// <param name="designer"></param>
		public ArticleDataSourceActionList(ArticleDataSourceDesigner designer) : base(designer.Component)
		{
			_designer = designer;
		}

		/// <summary>
		/// Gets or sets the SelectMethod property.
		/// </summary>
		public ArticleSelectMethod SelectMethod
		{
			get { return _designer.SelectMethod; }
			set { _designer.SelectMethod = value; }
		}

		/// <summary>
		/// Returns the collection of <see cref="T:System.ComponentModel.Design.DesignerActionItem"/>
		/// objects contained in the list.
		/// </summary>
		/// <returns>A <see cref="T:System.ComponentModel.Design.DesignerActionItem"/>
		/// array that contains the items in this list.</returns>
		public override DesignerActionItemCollection GetSortedActionItems()
		{
			DesignerActionItemCollection items = new DesignerActionItemCollection();
			items.Add(new DesignerActionPropertyItem("SelectMethod", "Select Method", "Methods"));
			return items;
		}
	}

	#endregion ArticleDataSourceActionList
	
	#endregion ArticleDataSourceDesigner
	
	#region ArticleSelectMethod
	
	/// <summary>
	/// Enumeration of method names available for the ArticleDataSource.SelectMethod property.
	/// </summary>
	public enum ArticleSelectMethod
	{
		/// <summary>
		/// Represents the Get method.
		/// </summary>
		Get,
		/// <summary>
		/// Represents the GetAll method.
		/// </summary>
		GetAll,
		/// <summary>
		/// Represents the GetPaged method.
		/// </summary>
		GetPaged,
		/// <summary>
		/// Represents the Find method.
		/// </summary>
		Find,
		/// <summary>
		/// Represents the GetByAlias method.
		/// </summary>
		GetByAlias,
		/// <summary>
		/// Represents the GetByAliasIsDisabled method.
		/// </summary>
		GetByAliasIsDisabled,
		/// <summary>
		/// Represents the GetByAliasIsDisabledIsRemoved method.
		/// </summary>
		GetByAliasIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByAliasIsRemoved method.
		/// </summary>
		GetByAliasIsRemoved,
		/// <summary>
		/// Represents the GetByIdIsDisabled method.
		/// </summary>
		GetByIdIsDisabled,
		/// <summary>
		/// Represents the GetByIdIsDisabledIsRemoved method.
		/// </summary>
		GetByIdIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByIdIsRemoved method.
		/// </summary>
		GetByIdIsRemoved,
		/// <summary>
		/// Represents the GetByIdLanguage method.
		/// </summary>
		GetByIdLanguage,
		/// <summary>
		/// Represents the GetByIdLanguageIsDisabled method.
		/// </summary>
		GetByIdLanguageIsDisabled,
		/// <summary>
		/// Represents the GetByIdLanguageIsDisabledIsRemoved method.
		/// </summary>
		GetByIdLanguageIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByIdLanguageIsRemoved method.
		/// </summary>
		GetByIdLanguageIsRemoved,
		/// <summary>
		/// Represents the GetByIdOriginalId method.
		/// </summary>
		GetByIdOriginalId,
		/// <summary>
		/// Represents the GetByIdOriginalIdIsDisabled method.
		/// </summary>
		GetByIdOriginalIdIsDisabled,
		/// <summary>
		/// Represents the GetByIdOriginalIdIsDisabledIsRemoved method.
		/// </summary>
		GetByIdOriginalIdIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByIdOriginalIdIsRemoved method.
		/// </summary>
		GetByIdOriginalIdIsRemoved,
		/// <summary>
		/// Represents the GetByIsDisabled method.
		/// </summary>
		GetByIsDisabled,
		/// <summary>
		/// Represents the GetByIsDisabledIsRemoved method.
		/// </summary>
		GetByIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByIsRemoved method.
		/// </summary>
		GetByIsRemoved,
		/// <summary>
		/// Represents the GetByLanguage method.
		/// </summary>
		GetByLanguage,
		/// <summary>
		/// Represents the GetByLanguageIsDisabled method.
		/// </summary>
		GetByLanguageIsDisabled,
		/// <summary>
		/// Represents the GetByLanguageIsDisabledIsRemoved method.
		/// </summary>
		GetByLanguageIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByLanguageIsRemoved method.
		/// </summary>
		GetByLanguageIsRemoved,
		/// <summary>
		/// Represents the GetByOriginalId method.
		/// </summary>
		GetByOriginalId,
		/// <summary>
		/// Represents the GetByOriginalIdIsDisabled method.
		/// </summary>
		GetByOriginalIdIsDisabled,
		/// <summary>
		/// Represents the GetByOriginalIdIsDisabledIsRemoved method.
		/// </summary>
		GetByOriginalIdIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByOriginalIdIsRemoved method.
		/// </summary>
		GetByOriginalIdIsRemoved,
		/// <summary>
		/// Represents the GetByOriginalIdLanguage method.
		/// </summary>
		GetByOriginalIdLanguage,
		/// <summary>
		/// Represents the GetByOriginalIdLanguageIsDisabled method.
		/// </summary>
		GetByOriginalIdLanguageIsDisabled,
		/// <summary>
		/// Represents the GetByOriginalIdLanguageIsDisabledIsRemoved method.
		/// </summary>
		GetByOriginalIdLanguageIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByOriginalIdLanguageIsRemoved method.
		/// </summary>
		GetByOriginalIdLanguageIsRemoved,
		/// <summary>
		/// Represents the GetById method.
		/// </summary>
		GetById
	}
	
	#endregion ArticleSelectMethod

	#region ArticleFilter
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilter&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Article"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ArticleFilter : SqlFilter<ArticleColumn>
	{
	}
	
	#endregion ArticleFilter

	#region ArticleExpressionBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlExpressionBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Article"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ArticleExpressionBuilder : SqlExpressionBuilder<ArticleColumn>
	{
	}
	
	#endregion ArticleExpressionBuilder	

	#region ArticleProperty
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ChildEntityProperty&lt;ArticleChildEntityTypes&gt;"/> class
	/// that is used exclusively with a <see cref="Article"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ArticleProperty : ChildEntityProperty<ArticleChildEntityTypes>
	{
	}
	
	#endregion ArticleProperty
}

